package com.neusoft.test;

import com.neusoft.config.SpringConfig;
import com.neusoft.model.UmsAdmin;
import com.neusoft.service.UmsAdminService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import javax.sql.DataSource;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @Author: duan
 * @Date: Create in 11:53 2020/10/28
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = SpringConfig.class)
public class SpringDemo {
    @Autowired
    private UmsAdminService umsAdminService;

    @Test
    public void insert() {
        UmsAdmin bean = new UmsAdmin(0L, "hehe", "123", "", "441924919@qq.com", "leo", "note", new Date(), new Date(), 1);
        boolean insert = umsAdminService.insert(bean);
        System.out.println(insert);
    }

    @Test
    public void update() {
        UmsAdmin bean = new UmsAdmin(9L, "hehe", "abc", "", "441924919@qq.com", "leo", "note", new Date(), new Date(), 1);
//        bean.setId();
        boolean insert = umsAdminService.update(bean);
        System.out.println(insert);
    }

    @Test
    public void delete() {
        boolean insert = umsAdminService.delete(8L);
        System.out.println(insert);
    }

    @Test
    public void queryById() {
        UmsAdmin umsAdmin = umsAdminService.queryById(9L);
        System.out.println(umsAdmin);
    }

    @Test
    public void queryList() {
        List<UmsAdmin> umsAdmins = umsAdminService.queryList();
        System.out.println(umsAdmins);
    }

    @Test
    public void queryListMap() {
        List<Map<String, Object>> maps = umsAdminService.queryListMap();
        System.out.println(maps);
    }

    @Test
    public void getCount() {
        Integer count = umsAdminService.getCount();
        System.out.println(count);
    }
}
